package com.example.musicrecommend.model.vo;

import com.example.musicrecommend.model.entity.Question;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * @author Maobohe
 * @createData 2024/5/28 10:04
 */
@Data
public class QuestionVO {
    /**
     * id
     */
    private Long id;

    /**
     * 题目类型：choose/blanking/subjective
     */
    private String questionType;

    /**
     * 题目内容
     */
    private String questionContent;

    /**
     * 知识点
     */
    private String knowledgePoint;

    /**
     * 难易度：0简单，1中等，3困难
     */
    private Integer difficulty;

    /**
     * 章节
     */
    private String chapter;

    /**
     * 错误率
     */
    private String errorRate;

    /**
     * 易错点
     */
    private String errorProne;

    /**
     * 贴图
     */
    private String texture;

    /**
     * 文字答案
     */
    private String solution;

    /**
     * 图片答案
     */
    private String picture;

    private static final long serialVersionUID = 1L;

    /**
     * VO包装类转实体对象
     * @param questionVO
     * @return
     */
    public static Question voToObj(QuestionVO questionVO) {
        if (questionVO == null) {
            return  null;
        }
        Question question = new Question();
        BeanUtils.copyProperties(questionVO, question);
        return question;
    }

    /**
     * 实体对象转 VO包装类
     * @param question
     * @return
     */
    public static  QuestionVO objToVo(Question question) {
        if (question == null) {
            return null;
        }
        QuestionVO questionVO = new QuestionVO();
        BeanUtils.copyProperties(question, questionVO);
        return questionVO;
    }
}
